package edu.mercer.sse.tasks.math;

import com.google.common.base.Function;

/**
 * Calculate accuracy of Pi.<p>
 *
 * Used to evaluate results of Monte Carlo approximation of Pi.<p>
 * 
 * @see MonteCarloPi
 */

public class PiAccuracyFunction implements Function<Double, Double>
{

	@Override
	public Double apply( final Double piEstimate )
	{
    	Double errAmount    = Math.abs( piEstimate - Math.PI ); 

    	Double errAmountPer = Math.abs( errAmount / Math.PI  ) / 
    			Math.PI * 100;
    	
    	return 100d - errAmountPer;
    	
	}//method

	
}//class
